function populateHoldCodeData(holdCodeModel) {
	jQuery("#s3list").jqGrid({
		url: "reloadHCFilter.do?cmd=" + holdCodeModel.cmd,
		datatype: "json",
	   	colNames: holdCodeModel.colNames,
	   	colModel: holdCodeModel.colModel,
		data: holdCodeModel.data,
	   	//rowNum:10,
		width : 460,
	    height: 300,
	    autowidth: false,
	    shrinkToFit: false,
	    headertitles : true,
	    //loadonce: true,
	   	//rowList:[10,20,30],
	   	pager: '#prowed3',
	    viewrecords: true,
		editurl: 'manipulateHCFilter.do?cmd=' + holdCodeModel.cmd,
		caption: holdCodeModel.title
	});

	jQuery("#s3list").jqGrid('sortableRows',
		{ update : function(e,ui) {
			var grid = $("#s3list");
			
			$("#lui_s3list").show();
			//$("#lui_"+$.jgrid.jqID($t.p.id)).hide();
            var posturl = grid.jqGrid('getGridParam', 'editurl') + "&oper=reorder"; 
            var neworder = $("#s3list").jqGrid("getDataIDs").join(',');
            //console.log(neworder);
            $.post( posturl, {order : neworder}, function(message,status) {
                if(status != 'success') {
                    alert(message);
                }
                
                $("#lui_s3list").hide(); 
                reloadgrid(grid); 
                  
            });
            
        }
	});
	jQuery("#s3list").jqGrid('navGrid',"#prowed3",{edit:false,add:false, refresh:false,search:false,del:holdCodeModel.deleteButton});
	//jQuery("#rowed3").jqGrid('inlineNav',"#prowed3", {addParams : {position: "last"}});
	
	//Bind the navigation and set the onEnter event 
	//jQuery("#rowed3").jqGrid('bindKeys', {} );
	
	$("#s3list").jqGrid('inlineNav', '#prowed3', { 
		addParams: { 
			position: "last", 
			addRowParams: {
					"keys": true
				}	
			}, 
		editParams: { 
			 "aftersavefunc": function(rowid, response) {
				 var grid = $("#s3list");
				
				 var text = response.responseText;
				 var jsonObj = $.parseJSON(text);
				 // show error message if having, then reload grid.
				 
				 if (!jsonObj.success) {
					 alert(jsonObj.message);
					 reloadgrid(grid);
				 }
				 
				 // reload grid to fetch new inserted id.
				 if (!$.isNumeric(rowid)) {
					 reloadgrid(grid); 
				 }
				 } 
		 	},
		 add: holdCodeModel.addButton
		 
		}
	);
}

function reloadgrid(grid) {
	grid.trigger("reloadGrid");
}
$(function() {
	createConfirmDialog();
	$( "#table-save-confirm" ).dialog({
        resizable: false,
        height:140,
        autoOpen: false,
        modal: true,
        buttons: {
            "Ok": function() {
            	$( this ).dialog( "close" );
            },
            Cancel: function() {
                $( this ).dialog( "close" );
            }
        }
    });
});